//
//  LYYNavigationController.m
//  LYYWeibo
//
//  Created by lanou3g on 15/10/12.
//  Copyright (c) 2015年 李岩岩. All rights reserved.
//

#import "LYYNavigationController.h"
// 按钮的选中文字颜色
#define LYYColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
#define  LYYTabBarButtonTitleSelectedColor LYYColor(3, 189, 249)

@interface LYYNavigationController ()

@end

@implementation LYYNavigationController

/**
 *第一次使用这个类的时候会调用（1个类只会调用1次）
 */
+ (void)initialize{

    
     //1.设置导航栏主题
    [self setupNavBarTheme];
    //2.设置导航栏按钮主题
    [self setupBarButtonItemTheme];
    
    
}
+ (void)setupBarButtonItemTheme{
    
    UIBarButtonItem *item = [UIBarButtonItem appearance];
    //设置背景
    
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = LYYTabBarButtonTitleSelectedColor;
    
    textAttrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:15];
    
    
    //设置文字属性
    [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    [item setTitleTextAttributes:textAttrs forState:UIControlStateHighlighted];
    
}

/**
 * 1.设置导航栏主题
 */
+ (void)setupNavBarTheme{
    
    //取出appearance对象
    UINavigationBar *navBar = [UINavigationBar appearance];
    //设置navBar的背景图片
//    [navBar setBackgroundImage:[UIImage imageNamed:@"nav"] forBarMetrics:UIBarMetricsDefault];
    
    
    //设置字体颜色
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = LYYTabBarButtonTitleSelectedColor;
    
    textAttrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:19];
    
    [navBar setTitleTextAttributes:textAttrs];
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    
    [super pushViewController:viewController animated:YES];
}


@end
